unit con_Demonstrativo;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Formulario_Padrao_Consulta, StdCtrls, Buttons, ExtCtrls, Grids, DBGrids,dbtables,db;

type
  TFrmCon_demonstrativo = class(TFrmConsulta)
    Label1: TLabel;
    edtNome: TEdit;
    dbgDemonstrativo: TDBGrid;
    procedure edtNomeKeyDown(Sender: TObject; var Key: Word;
      Shift: TShiftState);
    procedure FormActivate(Sender: TObject);
    procedure BtnFecharClick(Sender: TObject);
  private
    { Private declarations }
    procedure Fazconsulta;
  public
    { Public declarations }
    Dem_codigo  :string;
  end;

var
  FrmCon_demonstrativo: TFrmCon_demonstrativo;

implementation

uses cls_Demonstrativo,biblio,dm;

var Demonstrativo  : TDemonstrativo;
    tds            : Tdatasource;
    tq             : Tquery;


{$R *.DFM}

procedure TFrmCon_demonstrativo.edtNomeKeyDown(Sender: TObject;
  var Key: Word; Shift: TShiftState);
begin
  inherited;
  if key=12 then begin
    FazConsulta;
    edtNome.setfocus;
  end;
end;

procedure TFrmCon_demonstrativo.FormActivate(Sender: TObject);
begin
  inherited;
  tds:=TDataSource.create(FrmCon_demonstrativo);
  tq:=Tquery.create(FrmCon_demonstrativo);
  tq.databasename:=dmint.db.databasename;
  tq.active:=False;
  tds.DataSet:=tq;
  fazconsulta;
  edtnome.setfocus;
end;

procedure TFrmCon_demonstrativo.BtnFecharClick(Sender: TObject);
begin
  inherited;
  Dem_Codigo:=tq.fieldbyname('Dem_Codigo').asstring;
  tds.free;
  tq.free;
end;

procedure TFrmCon_demonstrativo.Fazconsulta;
begin
  if edtnome.text='' then
    edtnome.text := ' ';
  Demonstrativo:=TDemonstrativo.Create;
  Demonstrativo.Consultar(tq,edtNome.text);
  tq.open;
  Demonstrativo.free;
  dbgDemonstrativo.DataSource := tds;
  dbgDemonstrativo.Refresh;
end;

end.
